import { Column, CreateDateColumn, Entity, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';
import { EvaluateEntity } from './evaluates.entity';
import dayjs from 'dayjs';

@Entity({ name: 'products' })
class Product {
  @PrimaryGeneratedColumn({ zerofill: true })
  productId: number;

  @Column({ length: 50 })
  name: string;

  @Column('decimal', { precision: 8, scale: 2 })
  basePrice: number;

  @Column('int', { width: 8, zerofill: true })
  categoryId: number;

  //长度为12的int类型
  @Column({ length: 12, nullable: true })
  productCode: string;

  @Column('tinyint', { width: 1, default: 0 })
  returnGroud7: number;

  @Column('tinyint', { width: 1, default: 0 })
  provideHome: number;

  @Column('tinyint', { width: 1, default: 0 })
  persionPickUp: number;

  @Column('tinyint', { width: 1, default: 0 })
  damagedPackageReturn: number;

  @Column('tinyint', { width: 1, default: 0 })
  lightningRefund: number;

  @Column('tinyint', { width: 1, default: 0 })
  provideGlobal: number;

  @Column({ length: 50 })
  productOverview: string;

  @Column('int', { width: 8, zerofill: true })
  adminId: number;

  @Column('int', { width: 8, zerofill: false })
  totalStock: number;

  @Column({ length: 255, nullable: true })
  productChoice: string;

  @Column('tinyint', { width: 1, default: 2 })
  status: number;

  @Column({ length: 25, default: dayjs().format('YYYY-MM-DD HH:mm:ss') })
  createdTime: string;

  @Column('bigint', { width: 50, default: new Date().getTime() })
  createdTimestamp: number;

  @Column({ length: 255 })
  imageList: string;

  @OneToMany(() => EvaluateEntity, evaluate => evaluate.product)
  evaluates: EvaluateEntity[];
}

export {
  Product as ProductEntity
};